<div class="deploy_form">
    <div class="modal-header ">
        <button aria-hidden="true" type="button " class="close close-x" data-dismiss="modal"></button>
        <h3>新建虚拟私有网络(VPC)</h3>
    </div>
    <div class="modal-body">
        <div  class="form-horizontal" >
            <div class="control-group">
                <label class="control-label">VPC命名<span class="required">*</span></label>
                <div class="controls">
                    <input type="text" name="vpc_name" id="vpc_name" value="<?php echo $vpc_name;?>" class="span6 m-wrap">
                </div>
            </div>
            <div class="control-group">
                <label class="control-label">带宽<span class="required">*</span></label>
                <div class="controls">
                    <input type="text" name="bandwidth"value="<?php echo $bandwidth;?>" class="span2 m-wrap">Mbps
                </div>
            </div>
            <!--
            <div class="control-group">
                <label class="control-label">PPTP VPN<input type="checkbox" name="pptp_status" id="pptp_status"></label>
            </div>
            <div class="control-group">
                <label class="control-label">用户</label>
                <div class="controls">
                    <input name="pptp-username" type="text" disabled="disabled"  value="" class="span3 m-wrap">
                </div>
                <br/>
                <label class="control-label">密码</label>
                <div class="controls">
                    <input name="pptp-password" type="text" disabled="disabled"  value="" class="span3 m-wrap">
                </div>
            </div>
            -->
            <input name="app_id" type="hidden" value="<?php echo $app_id;?>">
            <input name="region" type="hidden" value="<?php echo $region;?>">
            <div class="modal-footer ">
                <button aria-hidden="true" type="button " class="btn close" data-dismiss="modal">取消</button>
                <?php if(isset($edit)){ ?>
                <button aria-hidden="true" id="vpc_edit_submit_btn" class="btn green btn-primary " type="button" value="<?php echo $app_id;?>"><i class="icon-ok"></i>修改</button>
                <?php }else{ ?>
                <button aria-hidden="true" id="vpc_submit_btn" class="btn green btn-primary " type="button" value="<?php echo $app_id;?>"><i class="icon-ok"></i>确认</button>
                <?php } ?>
            </div>
       </div>
    </div>
</div>


<script>

    $(document).keyup(function(event){
        if(event.keyCode ==13){
            $("#vpc_submit_btn").trigger("click");
            $("#vpc_edit_submit_btn").trigger("click");
        }
    });
    $(function(){
        //check vpc name exites
        $("input[name='vpc_name']").change(function(){
            var ef=$(this);
            $.ajax({
                url: 'index.php?route=deploy/vpc/check_vpc_name_exist',
                cache: false,
                dataType: 'json',
                type: 'POST',
                data: {
                    vpcname: $(this).val(),
                    app_id: $('input[name=\'app_id\']').val()
                },
                error: function() {
                },
                beforeSend: function() {
                    ef.after('<span class="wait">&nbsp;<img src="catalog/view/theme/default/image/loading.gif" alt="" /></span>');
                },
                complete: function() {
                    $('.wait').remove();
                },
                success: function(json) {
                    if(json['result']=='success'){
                        ef.removeClass();
                        ef.addClass("success");
                    }else{
                        ef.removeClass();
                        ef.addClass("error");
                    }
                }
            });
        });
        //pptp vpn status
        $("#pptp_status").click(function() {
            if ($(this).attr("checked")=="checked") {
                $("input[name=pptp-username]").removeAttr("disabled");
                $("input[name=pptp-password]").removeAttr("disabled");
            }else{
                $("input[name=pptp-username]").val("");
                $("input[name=pptp-password]").val("");
                $("input[name=pptp-username]").attr("disabled","disabled");
                $("input[name=pptp-password]").attr("disabled","disabled");
            }
        });
    })
</script>